package leetcode.code0467;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int findSubstringInWraproundString(String p) {
		int[] records = new int[26];
		int last = -1, max = 0;
		char[] cs = p.toCharArray();
		for (char c : cs) {
			int cur = c - 'a';
			max = (cur == last + 1) || (last == 25 && cur == 0) ? max + 1 : 1;
			if (max > records[cur]) {
				records[cur] = max;
			}
			last = cur;
		}
		int ans = 0;
		for (int num : records) {
			ans += num;
		}
		return ans;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		so.findSubstringInWraproundString("abcdefg");

	}

}
